package com.bangdao.app.jetpacktest.jetpack.databinding;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;

import com.bangdao.app.jetpacktest.R;
import com.bangdao.app.jetpacktest.databinding.ActivityTwoWayDataBinding1Binding;
import com.bangdao.app.jetpacktest.jetpack.databinding.viewmodel.TwoWayBindingViewModel1;
import com.bangdao.app.jetpacktest.jetpack.databinding.viewmodel.TwoWayBindingViewModel2;

/**
 * 双向绑定
 */
public class TwoWayDataBindingActivity1 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //创建DataBinding
        ActivityTwoWayDataBinding1Binding binding =
                DataBindingUtil.setContentView(this, R.layout.activity_two_way_data_binding1);
        //创建ViewModel
//        TwoWayBindingViewModel1 viewModel1 = new ViewModelProvider(this).get(TwoWayBindingViewModel1.class);
        ////建立绑定关系
        binding.setViewModel(new TwoWayBindingViewModel1());
    }
}